package net.seriousinc.SeriousMobile;

import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.webkit.WebView;

public class WebFragment extends Fragment {

	WebView v;
	String lastURL;
	public View onCreateView(LayoutInflater inflater, ViewGroup root, Bundle savedInstanceState)
	{
		 v = new WebView(getActivity());
		v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        v.setVerticalScrollBarEnabled(false);
		v.setHorizontalScrollBarEnabled(false);
		v.setBackgroundColor(Color.BLACK);
//    	v.setWebViewClient(client);
//    	v.setPictureListener(client);
    	v.getSettings().setJavaScriptEnabled(true);
    	v.getSettings().setLoadWithOverviewMode(true);
    	v.getSettings().setUseWideViewPort(true);
    	v.getSettings().setPluginsEnabled(true);
    	v.loadUrl("http://tv.seriousinc.net/mobile.php");
		
		return v;
	}
	public WebView getWebView() {
		return v;
	}
	
	@Override
    public void onConfigurationChanged(Configuration newConfig)
    {
    	super.onConfigurationChanged(newConfig);
    }
	
	public void onPause()
	{
		super.onPause();
		lastURL = v.getUrl();
		v.loadUrl("about:blank");
	}
	public void onResume()
	{
		super.onResume();
		if(lastURL != null)
			v.loadUrl(lastURL);
	}
	
}
